package com.example.myandroidapp1;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;

import com.example.myandroidapp1.dto.Person;

public class Set extends Activity implements OnClickListener, OnCheckedChangeListener {

	private TextView question, test;
	private Button returnData;
	private RadioGroup selectionList;

	private String gotBread,setData;
	private Person person;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.set);
		initialize();
		Bundle gotBasket = getIntent().getExtras();
		/*gotBread = gotBasket.getString("key");
		person = (Person) gotBasket.getSerializable("person");
		question.setText(person.getFirstName());*/
		
	}

	private void initialize() {
		question = (TextView) findViewById(R.id.tvQuestion);
		test = (TextView) findViewById(R.id.tvText);
		returnData = (Button) findViewById(R.id.bReturn);
		returnData.setOnClickListener(this);
		selectionList = (RadioGroup) findViewById(R.id.rgAnswers);
		selectionList.setOnCheckedChangeListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.bReturn:
			Intent person = new Intent();
			Bundle backPack = new Bundle();
			backPack.putString("answer", setData);
			person.putExtras(backPack);
			setResult(RESULT_OK, person);
			finish();
			break;

		default:
			break;
		}
	}

	@Override
	public void onCheckedChanged(RadioGroup group, int checkedId) {
		switch (checkedId) {
		case R.id.rCrazy:
			setData = "Probably Right!";
			break;
		case R.id.rHot:
			setData = "Definitely Right!";

			break;
		case R.id.rBoth:
			setData = "Spot on!";

			break;
		default:
			break;
		}
		test.setText(setData);
	}
}
